#pragma once

#include "mem.h"

namespace sfc::panicking {

struct Error {};

struct Location {
  const char* file = __builtin_FILE();
  int line = __builtin_LINE();
};

struct LocationFmt {
  const char* _ptr;
  usize _len;
  Location _loc;

 public:
  template <usize N>
  LocationFmt(const char (&s)[N], Location loc = {}) : _ptr{s}, _len{N - 1}, _loc{loc} {}
};

void panic_fmt(LocationFmt fmt, const auto&... args);

void assert_fmt(const auto& cond, LocationFmt fmt, const auto&... args) {
  if (!cond) {
    panicking::panic_fmt(fmt, args...);
  }
}

}  // namespace sfc::panicking
